<?php

$path	=	$_GET['path'];
$arr	=	explode('/', $path);

if(count($arr) > 1)
{
	switch($arr[1])
	{
		case 'access_token':
			
			$app_id	=	$_GET['client_id'];
			$secret	=	$_GET['client_secret'];
			$row	=	$DB->query("SELECT * FROM services WHERE app_id='".$app_id."' AND secret='".$secret."'");
			$row	=	$DB->fetch_row($row);
			if($row)
			{
				$time	=	time();
				$token	=	md5(uniqid(rand(), TRUE));
				$DB->query("INSERT INTO token_access(token_access,time)VALUES('".$token."','".$time."')");
				$arr	=	array('exp' => $time,'token_access' => $token);
				//header('Content-type: application/json');
				header('Content-type: text/json');
				print_r(($arr));die();
				
			}
		break;
	}
}